using System;
using System.Collections.Generic;


namespace DataObjects
{
	[Serializable]
	public class Department: IEquatable<Department>
	{

		#region Private Members

		private string _department_id; 
		private string _department_name; 
		private string _remark; 
		private string _parent_id; 
		private string _status; 		
		#endregion

		#region Constructor

		public Department()
		{
			_department_id = String.Empty; 
			_department_name = String.Empty; 
			_remark = String.Empty; 
			_parent_id = String.Empty; 
			_status = String.Empty; 
		}
		#endregion // End of Default ( Empty ) Class Constuctor

		#region Required Fields Only Constructor
		/// <summary>
		/// required (not null) fields only constructor
		/// </summary>
		public Department(
			string department_id, 
			string department_name)
			: this()
		{
			_department_id = department_id;
			_department_name = department_name;
			_remark = String.Empty;
			_parent_id = String.Empty;
			_status = String.Empty;
		}
		#endregion // End Constructor

		#region Public Properties
			
		public virtual string DepartmentId
		{
			get
			{ 
				return _department_id;
			}

			set	
			{	
				if( value == null )
					throw new ArgumentOutOfRangeException("Null value not allowed for DepartmentId", value, "null");
				
				if(  value.Length > 10)
					throw new ArgumentOutOfRangeException("Invalid value for DepartmentId", value, value.ToString());
				
				_department_id = value;
			}
		}
			
		public virtual string DepartmentName
		{
			get
			{ 
				return _department_name;
			}

			set	
			{	
				if( value == null )
					throw new ArgumentOutOfRangeException("Null value not allowed for DepartmentName", value, "null");
				
				if(  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for DepartmentName", value, value.ToString());
				
				_department_name = value;
			}
		}
			
		public virtual string Remark
		{
			get
			{ 
				return _remark;
			}

			set	
			{	
				if(  value != null &&  value.Length > 200)
					throw new ArgumentOutOfRangeException("Invalid value for Remark", value, value.ToString());
				
				_remark = value;
			}
		}
			
		public virtual string ParentId
		{
			get
			{ 
				return _parent_id;
			}

			set	
			{	
				if(  value != null &&  value.Length > 10)
					throw new ArgumentOutOfRangeException("Invalid value for ParentId", value, value.ToString());
				
				_parent_id = value;
			}
		}
			
		public virtual string Status
		{
			get
			{ 
				return _status;
			}

			set	
			{	
				if(  value != null &&  value.Length > 10)
					throw new ArgumentOutOfRangeException("Invalid value for Status", value, value.ToString());
				
				_status = value;
			}
		}
			
				
		#endregion 

		#region Public Functions

		#endregion //Public Functions

		#region Equals And HashCode Overrides
		/// <summary>
		/// local implementation of Equals based on unique value members
		/// </summary>
		public override bool Equals( object obj )
		{
			if( this == obj ) return true;
			if( ( obj == null ) || ( obj.GetType() != this.GetType() ) ) return false;
			Department castObj = (Department)obj; 
			return ( castObj != null ) &&
				( this._department_id == castObj.DepartmentId );
		}
		
		/// <summary>
		/// local implementation of GetHashCode based on unique value members
		/// </summary>
		public override int GetHashCode()
		{
			
			int hash = 57; 
			hash = 27 ^ hash ^ _department_id.GetHashCode();
			return hash; 
		}
		#endregion
		
		#region IEquatable members

		public bool Equals(Department other)
		{
			if (other == this)
				return true;
		
			return ( other != null ) &&
				( this._department_id == other.DepartmentId );
				   
		}

		#endregion
		
	}
}
